unit BaseChildGridBtnForm;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, BaseChildGridForm, Menus, DBActns, StdActns, ActnList, ImgList,
  DB, ComCtrls, ExtCtrls, StdCtrls, MisString,
  typinfo, Buttons, RzButton, Mask,
  cxGraphics, cxControls, cxLookAndFeels,
  cxLookAndFeelPainters, cxStyles, dxSkinsCore, dxSkinsDefaultPainters,
  dxSkinscxPCPainter, cxDataStorage,
  cxEdit, cxDBData, cxClasses, cxGridCustomView,
  cxGridCustomTableView, cxGridTableView, cxGridDBTableView, cxGrid,
  cxContainer, cxLabel, cxGridBandedTableView, cxGridDBBandedTableView,
  Uni, cxGridCustomPopupMenu, dxSkinsForm,
  cxNavigator, cxCustomData, cxFilter, cxData, cxGridPopupMenu, MemDS, DBAccess,
  System.Actions, System.ImageList, cxGridLevel;

type
  TfrmBaseChildGridBtnForm = class(TfrmBaseChildGridForm)
    PanelDataEnter: TPanel;
{$WARN SYMBOL_DEPRECATED ON}
    procedure FormCreate(Sender: TObject);
    procedure PopmnuModifyRecordClickClick(Sender: TObject);
    procedure PopmnuNewRecordClick(Sender: TObject);
  private
    { Private declarations }
    procedure SetBtnState;
  protected
    UploadDataSetState: TDataSetState;
  public
    { Public declarations }
  end;

var
  frmBaseChildGridBtnForm: TfrmBaseChildGridBtnForm;

implementation

{$R *.dfm}

procedure TfrmBaseChildGridBtnForm.FormCreate(Sender: TObject);
begin
  inherited;   

  SetBtnState;
  P_ISSaveOK := false;
end;

procedure TfrmBaseChildGridBtnForm.SetBtnState;
var
  lsState: TDataSetState;
begin
  if not MainDataSet.Active then exit;
  lsState := MainDataSet.State;

  if lsState in [dsInsert, dsEdit] then
    SetControlReadOnly(PanelDataEnter, false)
  else
    SetControlReadOnly(PanelDataEnter, true);

  self.MainDBGrid.Enabled := not (lsState in [dsInsert, dsEdit]);

end;

procedure TfrmBaseChildGridBtnForm.PopmnuModifyRecordClickClick(
  Sender: TObject);
begin
  inherited;
  self.UploadDataSetState := dsEdit;
end;

procedure TfrmBaseChildGridBtnForm.PopmnuNewRecordClick(Sender: TObject);
begin
  inherited;
  self.UploadDataSetState := dsInsert;
end;

end.

